/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.brain.core.dto;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Ronald
 */
@Entity
@Table(name = "TCORE_CATALOGO")
public class CatalogoDto extends ComunDto implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "SEQ_TCORE_CATALOGO")
    @TableGenerator(name = "SEQ_TCORE_CATALOGO", table = "TCORE_ENTIDAD", pkColumnName = "NOMBRE", valueColumnName = "CORRELATIVO", pkColumnValue = "TCORE_CATALOGO", allocationSize = 1)
    private Long id;
    @Basic(optional = false)
    @NotNull
    @Size(max = 200)
    @Column(name = "NOMBRE")
    private String nombre;
    @Size(max = 500)
    @Column(name = "DESCRIPCION")
    private String descripcion;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "ESTADO")
    private Boolean estado;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "TIPO")
    private String tipo;
    @Transient
    private String tipoDesc;
    

    @Column(name = "EMPRESA")
    private Long empresa;
    
    @OneToMany(mappedBy = "catalogoDto")
    private List<ParametroDto> listaParametros;

    public CatalogoDto() {
    }

    public CatalogoDto(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Boolean getEstado() {
        return estado;
    }

    public void setEstado(Boolean estado) {
        this.estado = estado;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public Long getEmpresa() {
        return empresa;
    }

    public void setEmpresa(Long empresa) {
        this.empresa = empresa;
    }

    public List<ParametroDto> getListaParametros() {
        return listaParametros;
    }

    public void setListaParametros(List<ParametroDto> listaParametros) {
        this.listaParametros = listaParametros;
    }

    public String getTipoDesc() {
        if (this.tipo.equalsIgnoreCase("E")){
            return "EMPRESA";
        }else if (this.tipo.equalsIgnoreCase("N")){
            return "NEGOCIO";
        }else if (this.tipo.equalsIgnoreCase("S")){
            return "SISTEMA";
        }else {
            return "OTROS";
        } 
    }

    public void setTipoDesc(String tipoDesc) {
        this.tipoDesc = tipoDesc;
    }

    
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CatalogoDto)) {
            return false;
        }
        CatalogoDto other = (CatalogoDto) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.brain.core.dto.CatalogoDto[ id=" + id + " ]";
    }
    
}
